import { createRouter, createWebHistory } from 'vue-router'
import Home from '../pages/Home.vue'
import Query from '../pages/Query.vue'
import Display from '../pages/Display.vue'

const routes = [
  { path: '/', name: 'Home', component: Home },
  { path: '/query', name: 'Query', component: Query },
  { path: '/display', name: 'Display', component: Display },
  // 兼容支付宝回跳路径的拼写错误：/dispaly -> /display
  { path: '/dispaly', redirect: (to) => ({ name: 'Display', query: to.query }) },
  { path: '/dispaly/', redirect: (to) => ({ name: 'Display', query: to.query }) },
]

const router = createRouter({
  history: createWebHistory(),
  routes,
  scrollBehavior() {
    return { top: 0 }
  }
})

export default router